package org.netwia.networks;

import java.util.NoSuchElementException;

/**
 * Defines the interface for the connector of network to the outer world.
 * Remote connector is responsible for sending and receiving network parameters.
 * This is here to allow networks over the multiple computers to work together. 
 * 
 * @author radek.hecl
 *
 * @param <T> network parameter type
 */
public interface RemoteNetworkConnector<T> {
    
    /**
     * Sends the message to the remote client.
     * 
     * @param targetClient name of the target client
     * @param packageName name of the package
     * @param data data blob
     */
    public void sendOutput(String targetClient, String packageName, T data);
    
    /**
     * Returns true if next input is ready for the specified package name, false otherwise.
     * If next input is ready, then method getNextInput can be called 1 time with same packageName without risking the exception.
     * 
     * @param packetName name of the interested package
     * @return true if input is ready, false otherwise 
     */
    public boolean isNextInputReady(String packageName);
    
    /**
     * Returns the next input for the specified package name.
     *
     * @param packetName name of the interested package
     * @return next input
     * @throws NoSuchElementException if there is no input ready
     */
    public T getNextInput(String packageName);

}
